package com.pig4cloud.pigx.wallet.mq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class WalletMQ {

	/**
	 * Direct交换机
	 *
	 * @return
	 */
	@Bean
	public Exchange walletDriveExchange() {
		return new TopicExchange("wallet.drive.exchange", true, false);
	}

	/**
	 * 队列
	 *
	 * @return
	 */
	@Bean
	public Queue walletRechargeQueue() {
		return new Queue("wallet.recharge.queue", true, false, false);
	}

	/**
	 * 绑定 将队列和交换机绑定, 并设置路由键routingKey
	 *
	 * @return
	 */
	@Bean
	public Binding walletDriveRechargeBinding() {
		return new Binding(
				"wallet.recharge.queue",
				Binding.DestinationType.QUEUE,
				"wallet.drive.exchange",
				"wallet.drive.recharge.binding",
				null);
	}

	@Bean
	public Queue walletWithdrawalQueue() {
		return new Queue("wallet.withdrawal.queue", true, false, false);
	}

	@Bean
	public Binding walletDriveWithdrawalBinding() {
		return new Binding(
				"wallet.withdrawal.queue",
				Binding.DestinationType.QUEUE,
				"wallet.drive.exchange",
				"wallet.drive.withdrawal.binding",
				null);
	}

	@Bean
	public Queue walletImputationQueue() {
		return new Queue("wallet.imputation.queue", true, false, false);
	}

	@Bean
	public Binding walletDriveImputationBinding() {
		return new Binding(
				"wallet.imputation.queue",
				Binding.DestinationType.QUEUE,
				"wallet.drive.exchange",
				"wallet.drive.imputation.binding",
				null);
	}

	@Bean
	public Queue walletEmailQueue() {
		return new Queue("wallet.email.queue", true, false, false);
	}

	@Bean
	public Binding walletDriveEmailBinding() {
		return new Binding(
				"wallet.email.queue",
				Binding.DestinationType.QUEUE,
				"wallet.drive.exchange",
				"wallet.drive.email.binding",
				null);
	}
}
